/**
 * @file lambad.cpp
 * @author your name (you@domain.com)
 * @brief 练习lambda表达式的使用，使用lambda表达式进行参数传递
 * 参考资料: https://blog.csdn.net/DumpDoctorWang/article/details/81903140
 * @version 0.1
 * @date 2022-03-22
 * 
 * @copyright Copyright (c) 2022
 * 
 */
#include <iostream>
#include <string>
template <typename T>
void print_me(T f)
{
    using namespace std;
    cout << f() << endl;
}

int main_lambda()
{
    auto glambda = [](auto a, auto&& b) { return a < b; };
    bool b = glambda(3, 3.14); // ok
    using namespace std;
    cout << "glambda result: " << b << endl;

    int num = 100;
    auto aLambda = [&]()->std::string {
        num = num + 1;
        return std::to_string(num);
    };
    
    print_me(aLambda);
    print_me(aLambda);
    
    return 0;
}
